//package com.acheng.ws.client;
//
//import com.acheng.ws.client.listener.WebSocketListener;
//import io.netty.channel.Channel;
//import io.netty.handler.codec.http.FullHttpResponse;
//import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import java.net.URISyntaxException;
//
//public class MainClass {
//
//    private static Logger log = LoggerFactory.getLogger(MainClass.class);
//
//    public static void main(String[] args) {
//        try {
//            AbstractClient client = new AbstractClient("ws://rtrans.yunjivip.cn/rasr/", new WebSocketListener() {
//                @Override
//                public void onOpen(Channel webSocket, FullHttpResponse response) {
//                    log.info("链接成功，链接id={}", webSocket.id().asLongText());
////                    webSocket.writeAndFlush(new TextWebSocketFrame("{\n" +
////                            "  \"action\":\"RASR\",\n" +
////                            "  \"flag\":\"start\",\n" +
////                            "  \"asrFormat\":\"pcm\",\n" +
////                            "  \"from\":122,\n" +
////                            "  \"ext\":\"123456\",\n" +
////                            "  \"to\":26\n" +
////                            "}"));
//                }
//
//                @Override
//                public void onMessage(Channel webSocket, String text) {
//                    log.info("文本内容，链接id={}，内容={}", webSocket.id().asLongText(), text);
//                }
//
//                @Override
//                public void onMessage(Channel webSocket, byte[] bytes) {
//                    log.info("二进制，链接id={}，内容长度={}", webSocket.id().asLongText(), bytes.length);
//                }
//
//                @Override
//                public void onClosing(Channel webSocket, int code, String reason) {
//                    log.info("onClosing，链接id={}，code={}，原因={}", webSocket.id().asLongText(), code, reason);
//                }
//
//                @Override
//                public void onClosed(Channel webSocket, int code, String reason) {
//                    log.info("onClosed，链接id={}，code={}，原因={}", webSocket.id().asLongText(), code, reason);
//                }
//
//                @Override
//                public void onFailure(Channel webSocket, Throwable t, FullHttpResponse response) {
//                    log.info("onFailure，链接id={}，code={}", webSocket.id().asLongText(), response.status().code(), t);
//                }
//
//                @Override
//                public void onFailure(Channel webSocket, Throwable t) {
//                    log.info("onFailure，链接id={}，code={}", webSocket.id().asLongText(), t);
//                }
//            }) {
//            };
//            client.addHeader("vvv", "aaaa");
//            client.init();
////            Thread.sleep(2000);
////            client.send("{  \"action\":\"RASR\",  \"flag\":\"start\",  \"asrFormat\":\"pcm\",  \"from\":122,  \"ext\":\"123456\",  \"to\":26}");
//
//            Thread.sleep(4000);
//
//            for (int i = 0; i < 10; i++) {
//                System.out.println(client.ping());
//                Thread.sleep(800);
//            }
//
////            client.shutdown();
////            Thread.sleep(2000);
////            client.send("{\n" +
////                    "  \"action\":\"RASR\",\n" +
////                    "  \"flag\":\"start\",\n" +
////                    "  \"asrFormat\":\"pcm\",\n" +
////                    "  \"from\":122,\n" +
////                    "  \"ext\":\"123456\",\n" +
////                    "  \"to\":26\n" +
////                    "}");
//        } catch (URISyntaxException | InterruptedException e) {
//            e.printStackTrace();
//        }
//        while (true) {
//        }
//    }
//}
